<template>
  <div class="my-store-container">
    <user-bg></user-bg>
    <div class="down-content">
      我的门店
      <i class="el-icon-arrow-down"></i>
    </div>

    <div class="condition">
      <div class="date-time space-between">
        <span class="zhuce">注册时间：</span>
        <div class="time space-between">
          <span class="start-date" @click="startDateFun()">{{startDate}}</span>
          <span class="zhi">至</span>
          <span class="end-date" @click="endDateFun()">{{endDate}}</span>
        </div>
        <div class="search-btn">查询</div>
      </div>

      <div class="search-box space-between">
        <div class="select flex-start" @click="isShowType = true">
          <span>{{selectName}}</span>
          <i class="el-icon-arrow-down"></i>
        </div>
        <el-input class="co-search-input" clearable v-model="searchValue" placeholder="请输入内容"></el-input>
        <span class="search-btn" @click="storelist">
          <i class="el-icon-search"></i>
        </span>
      </div>

      <div class="type-title space-between">
        <span>门店名</span>
        <span>电话</span>
      </div>

      <ul class="list">
        <li v-for="item in store_list" :key="item.store_id" @click="show_detail(item.store_id)">
          <div class="first space-between">
            <span class="name font-over">{{item.store_name}}</span>
            <span class="phone font-over">{{item.store_contact_mobile}}</span>
          </div>
          <div class="second space-between">
            <span class="name font-over">
              <i class="el-icon-location-outline"></i>
              {{item.store_address}}
            </span>
            <span class="phone font-over">
              <i class="icon iconfont iconyonghu"></i>
              {{item.store_contact}}
            </span>
          </div>
        </li>
      </ul>

      <!--详情-->
      <div class="cash-withdrawal" v-if="isShowDetail">
        <!--提现-->
        <i class="close el-icon-close" @click="isShowDetail = false"></i>
        <p class="t">提现金额</p>
        <ul class="address">
          <li class="flex-start">
            <i class="icon iconfont icondingweiweizhizuobiaoxianxing"></i>
            <span class="name">{{store_info.store_address}}</span>
          </li>
          <li class="flex-start">
            <i class="icon iconfont icondianhua"></i>
            <span class="name">{{store_info.store_contact}}</span>
          </li>
          <li class="flex-start">
            <i class="icon iconfont iconyonghu"></i>
            <span class="name">{{store_info.store_contact_mobile}}</span>
          </li>
          <li class="flex-start">
            <i class="icon iconfont iconshijian"></i>
            <span class="name">{{store_info.create_time|timeToNumber}}</span>
          </li>
        </ul>
        <div class="money">营业额： 15元</div>
      </div>

      <!--详情-->
      <div class="cash-withdrawal" v-if="isShowType">
        <!--提现-->
        <i class="close el-icon-close" @click="isShowType = false"></i>
        <ol class="ol space-between-wrap">
          <li
            v-for="(item, index) in nameList"
            :key="index"
            @click="changeType(item.name, item.searchtype)"
          >{{item.name}}</li>
        </ol>
      </div>
    </div>

    <mt-datetime-picker
      v-model="startDate"
      type="date"
      ref="picker"
      year-format="{value} 年"
      month-format="{value} 月"
      date-format="{value} 日"
      @confirm="handleStartDate"
    ></mt-datetime-picker>

    <mt-datetime-picker
      v-model="endDate"
      type="date"
      ref="picker2"
      year-format="{value} 年"
      month-format="{value} 月"
      date-format="{value} 日"
      @confirm="handleEndDate"
    ></mt-datetime-picker>
    <bot-contact></bot-contact>
  </div>
</template>

<script>
import userBg from "@/components/userBg";
import botContact from "@/components/botContact";
import { Toast } from "mint-ui";
import { Cell } from "mint-ui";
import { DatetimePicker } from "mint-ui";
import constant from "@/util/constant";
import http from "@/util/http";
import util from "@/util/util";
export default {
  name: "index",
  data() {
    return {
      moneyNum: "",
      isShowMoney: false,
      startDate: "",
      endDate: "",
      search: "",
      searchValue: "",
      selectName: "门店",
      searchtype: "store",
      isShowDetail: false,
      isShowType: false,
      nameList: [
        {
          name: "门店",
          searchtype: "store"
        },
        {
          name: "电话",
          searchtype: "tel"
        },
        {
          name: "区域",
          searchtype: "area"
        }
      ],
      store_list: [],
      store_info: {}
    };
  },
  components: {
    userBg,
    botContact,
    Cell,
    DatetimePicker
  },
  filters: {
    timeToNumber: function(time) {
      return util.timeToNumber(time);
    }
  },
  computed: {},
  created() {},
  mounted() {
    this.storelist();
  },
  methods: {
    storelist() {
      http.get(this, {
        url: "store/index",
        data: {
          token: localStorage.getItem("user_token"),
          searchtype: this.search,
          startDate: this.startDate,
          endDate: this.endDate,
          search: this.searchValue
        },
        dataType: "json",
        success: function(data) {
          console.log("门店信息:", data);
          if (data.status == 1) {
            this.store_list = data.info.list;
          } else {
          }
        }
      });
    },
    show_detail(store_id) {
      http.get(this, {
        url: "store/detail",
        data: {
          token: localStorage.getItem("user_token"),
          store_id: store_id
        },
        dataType: "json",
        success: function(data) {
          console.log("门店详细信息:", data);
          if (data.status == 1) {
            this.store_info = data.info;
            this.isShowDetail = true;
          } else {
          }
        }
      });
    },
    handleStartDate(time) {
      //开始时间回调
      console.log(this.$utils.timeToNumber(time));
      let time2 = this.$utils.timeToNumber(time);
      this.startDate = time2.substring(0, 10);
    },
    handleEndDate(time) {
      //结束时间回调
      console.log(this.$utils.timeToNumber(time));
      let time2 = this.$utils.timeToNumber(time);
      this.endDate = time2.substring(0, 10);
    },
    startDateFun() {
      //开始时间
      this.$refs.picker.open();
      this.$refs.picker2.close();
    },
    endDateFun() {
      //结束时间
      this.$refs.picker.close();
      this.$refs.picker2.open();
    },
    changeType(name, searchtype) {
      this.selectName = name;
      this.search = searchtype;
      this.isShowType = false;
    }
  }
};
</script>

<style lang="less" scoped>
.promise(@css, @args) {
  @{css}: @args;
  -webkit-@{css}: @args;
  -moz-@{css}: @args;
  -ms-@{css}: @args;
  -o-@{css}: @args;
}
.my-store-container {
  padding-bottom: 140/37.5rem;
  .down-content {
    width: 100%;
    height: 90/37.5rem;
    line-height: 90/37.5rem;
    text-align: center;
    color: #666;
    font-size: 32/37.5rem;
    background: #fff;
    border-bottom: 12/37.5rem solid #eee;
  }
  .condition {
    position: relative;
    .date-time {
      padding: 0.8rem 20/37.5rem;
      .zhuce {
        font-size: 26/37.5rem;
        color: #666;
      }
      .time {
        width: 60%;
        .start-date {
          width: 40%;
          font-size: 28/37.5rem;
          color: #666;
          text-align: center;
        }
        .zhi {
          font-size: 28/37.5rem;
          width: 1rem;
        }
        .end-date {
          width: 40%;
          font-size: 28/37.5rem;
          color: #666;
          text-align: center;
        }
      }
      .search-btn {
        font-size: 26/37.5rem;
        color: #fff;
        background: #ff4d4d;
        padding: 0.2rem 0.4rem;
        margin-top: -0.2rem;
        .promise(border-radius, 1rem);
      }
    }
    .search-box {
      margin: 0 15/37.5rem;
      padding: 0 15/37.5rem;
      height: 80/37.5rem;
      background: #eee;
      .promise(border-radius, 0.3rem);
      .select {
        width: 16%;
        font-size: 28/37.5rem;
        color: #666;
        line-height: 80/37.5rem;
        i {
          line-height: 80/37.5rem;
          margin-left: 0.3rem;
        }
      }
      .co-search-input {
        width: 68%;
        font-size: 28/37.5rem;
        margin-left: -0.9rem;
      }
      .search-btn {
        width: 8%;
        line-height: 80/37.5rem;
        font-size: 42/37.5rem;
        color: #666;
      }
    }
    .type-title {
      font-size: 28/37.5rem;
      color: #666;
      margin: 1rem 20/37.5rem;
      span {
        width: 70%;
        text-align: left;
        & + span {
          width: 26%;
        }
      }
    }
    .list {
      margin: 0 20/37.5rem 1rem;
      li {
        padding: 0.6rem 0;
        border-bottom: 1px solid #ddd;
        .first {
          font-size: 30/37.5rem;
          color: #666;
          margin-bottom: 0.6rem;
          .name {
            width: 70%;
          }
          .phone {
            width: 26%;
          }
        }
        .second {
          font-size: 24/37.5rem;
          color: #666;
        }
      }
    }
  }
  .cash-withdrawal {
    position: absolute;
    top: 100/37.5rem;
    left: 0;
    width: 100%;
    background: #fff;
    height: 700/37.5rem;
    border-bottom: 1px solid #ccc;
    z-index: 10;
    padding: 60/37.5rem 0;
    .promise(box-sizing, border-box);
    .promise(box-shadow, 1px 0 5px #999);
    .close {
      position: absolute;
      top: 32/37.5rem;
      right: 32/37.5rem;
      z-index: 10;
      font-size: 34/37.5rem;
    }
    .t {
      font-size: 32/37.5rem;
      color: #666;
      margin: 0 20/37.5rem 30/37.5rem;
    }
    .address {
      padding: 0 20/37.5rem;
      border-bottom: 1px solid #ddd;
      li {
        line-height: 70/37.5rem;
        .icon {
          font-size: 42/37.5rem;
          color: #666;
          margin-right: 0.3rem;
        }
        .name {
          font-size: 28/37.5rem;
          color: #666;
        }
      }
    }
    .money {
      text-align: center;
      font-size: 36/37.5rem;
      margin-top: 1rem;
      color: #bc9f5b;
    }
    .ol {
      margin: 0.8rem 20/37.5rem 0;
      li {
        width: 30%;
        padding: 0.4rem 0;
        background: #eee;
        color: #666;
        font-size: 28/37.5rem;
        text-align: center;
      }
    }
  }
}
</style>
<style>
.co-search-input input {
  border: none !important;
  outline: none !important;
  font-size: 36/37.5rem !important;
  color: #666 !important;
  padding: 0 0.3rem !important;
  background: #eee !important;
}
</style>
